/* CoralCube | Massively Multiplayer Online Role-Playing Game(MMORPG) Emulator.
|* 
|* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
|*               2008-2010 TrinityCore <http://www.trinitycore.org/>
|*               2008-2010 CoralCube <http://www.CoralCube.com/>
|*
|* This program is free software. You can redistribute it and/or modify it under the terms of 
|* the GNU General Public License as published by the Free Software Foundation, either 
|* version 2 of the License.
|*
|* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, 
|* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
|* See the GNU General Public License for more details.
|*
|* You should have received a copy of the GNU General Public License along with this program. 
|* If not, see <http://www.gnu.org/licenses/>.
|*/

/* ScriptData
SDName: Boss_Gahz'ranka
SD%Complete: 85
SDComment: Massive Geyser with knockback not working. Spell buggy.
SDCategory: Zul'Gurub
EndScriptData */

#include "ScriptPCH.h"

#define SPELL_FROSTBREATH            16099
#define SPELL_MASSIVEGEYSER          22421                  //Not working. Cause its a summon...
#define SPELL_SLAM                   24326

class boss_gahzranka : public CreatureScript
{
    public:

        boss_gahzranka() : CreatureScript("boss_gahzranka") { }

        struct boss_gahzrankaAI : public ScriptedAI
        {
            boss_gahzrankaAI(Creature *c) : ScriptedAI(c) { }
            uint32 Frostbreath_Timer;
            uint32 MassiveGeyser_Timer;
            uint32 Slam_Timer;

            void Reset()
            {
                Frostbreath_Timer = 8000;
                MassiveGeyser_Timer = 25000;
                Slam_Timer = 17000;
            }

            void EnterCombat(Unit * /*who*/)
            {
            }

            void UpdateAI(const uint32 diff)
            {
                //Return since we have no target
                if (!UpdateVictim())
                    return;

                //Frostbreath_Timer
                if (Frostbreath_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_FROSTBREATH);
                    Frostbreath_Timer = 7000 + rand()%4000;
                } else Frostbreath_Timer -= diff;

                //MassiveGeyser_Timer
                if (MassiveGeyser_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_MASSIVEGEYSER);
                    DoResetThreat();

                    MassiveGeyser_Timer = 22000 + rand()%10000;
                } else MassiveGeyser_Timer -= diff;

                //Slam_Timer
                if (Slam_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SLAM);
                    Slam_Timer = 12000 + rand()%8000;
                } else Slam_Timer -= diff;

                DoMeleeAttackIfReady();
            }
        };

        CreatureAI* GetAI(Creature* pCreature) const
        {
            return new boss_gahzrankaAI(pCreature);
        }
};

void AddSC_boss_gahzranka()
{
    new boss_gahzranka();
}

